package com.vitabuybuy.tv.ui.mine.talent.goods.viewmodel

import android.view.View
import androidx.databinding.ObservableArrayList
import com.vitabuybuy.tv.BR
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.inter.OnCommodityItemClickListener
import com.library.common.base.BaseViewModel
import com.library.common.base.MessageModel
import com.library.common.net.loadingtype.LoadingType
import me.tatarka.bindingcollectionadapter2.ItemBinding
import me.tatarka.bindingcollectionadapter2.OnItemBind

class MyCommodityViewModel :BaseViewModel(){

    val itemOnClickListener = object : OnCommodityItemClickListener {
        override fun onViewGoodsDetailClick(item: String, position: Int) {
            defUI.msgEvent.postValue(MessageModel(1,arg1 = position))
        }

        override fun onViewGoodsTaskClick(item: String, position: Int) {
            defUI.msgEvent.postValue(MessageModel(2,arg1 = position))
        }
    }

    val goodsList = ObservableArrayList<String>()

    val goodsBinding: OnItemBind<String> =
        OnItemBind { itemBinding: ItemBinding<Any>, position: Int, _: String ->
            itemBinding.set(BR.itemBean, R.layout.item_commodity_1).bindExtra(BR.position, position)
                .bindExtra(BR.listenner, itemOnClickListener)
        }

    fun getData() {
        statusView.set(LoadingType.SHOW_CONTENT)
        goodsList.addAll(arrayListOf("", "", "", ""))
    }
}
